package com.ygxsk.carhome.ui.archive;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.gyf.immersionbar.ImmersionBar;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.park.keyboard.InputViewSelectKeyboard;
import com.park.keyboard.OnInputChangedListener;
import com.park.keyboard.PopupKeyboard;
import com.park.keyboard.view.InputView;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.alertview.AlertView;
import com.ygxsk.carhome.alertview.OnItemClickListener;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.enumwrap.ArchiveUpdateType;
import com.ygxsk.carhome.enumwrap.ArchiveVehicleType;
import com.ygxsk.carhome.enumwrap.CarLicenseNumberType;
import com.ygxsk.carhome.event.EventArchiveDetail;
import com.ygxsk.carhome.greendao.CarBrandLargeCategoryDaoManager;
import com.ygxsk.carhome.greendao.CarBrandSeriesLineDaoManager;
import com.ygxsk.carhome.listener.DoSomeThingListener;
import com.ygxsk.carhome.listener.ErrorParentExtraSingle;
import com.ygxsk.carhome.listener.GainDataCallBackListener;
import com.ygxsk.carhome.listener.MyKeyboardListener;
import com.ygxsk.carhome.listener.RxBus;
import com.ygxsk.carhome.response.CarBrandLargeCategory;
import com.ygxsk.carhome.response.CarBrandSeriesLineSmallCategory;
import com.ygxsk.carhome.response.CarInfoVehicleBean;
import com.ygxsk.carhome.response.FileCarInfoAddSubmitUpLoadSingle;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.rxbus.RxBusCarBrand;
import com.ygxsk.carhome.rxbus.RxBusCarSeriesLineSmall;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.leads.LeadsCarBrandLargeCategorySelectPopu;
import com.ygxsk.carhome.ui.leads.LeadsCarBrandSeriesLineSmalCategorySelectPopu;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.VehiclePlateNoUtil;
import com.ygxsk.carhome.views.ClearEditTextTouch;
import com.ygxsk.integrated.retrofit.Parameterkey;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-29  16:11
 * @Description:汽车的信息编辑，也是用在 档案提交的中间页面,单独编辑页
 */
public class CarInfoEditActivity extends ErrorActivity implements ErrorParentExtraSingle {

    //车辆品牌
    @BindView(R.id.linearlayoutcarinfowrap_edit)
    LinearLayout linearlayoutcarinfowrap_edit;

    //车辆品牌的填充文字
    @BindView(R.id.textviewebrandmodel_edit)
    TextView textviewebrandmodel_edit;

    //车系的外侧包裹
    @BindView(R.id.layoutcarmodelsecondside_edit)
    LinearLayout layoutcarmodelsecondside_edit;

    //车系的文字填充
    @BindView(R.id.textviewcarmodelsecond_edit)
    TextView textviewcarmodelsecond_edit;

    //车型-手动输入的
    @BindView(R.id.editviewinputevaluatecarmodel_edit)
    ClearEditTextTouch editviewinputevaluatecarmodel_edit;


    //新能源提示，
//    @BindView(R.id.imgiconinmiddle_edit)
//    ImageView imgIcon;

    //车架号
    @BindView(R.id.editviewcarframe_edit)
    ClearEditTextTouch editviewcarframe_edit;

    //发动机号
    @BindView(R.id.editviewcarmotor_edit)
    ClearEditTextTouch editviewcarmotor_edit;

    //车牌号-手动输入的
//    @BindView(R.id.editviewcarcard_edit)
//    ClearEditTextTouch editviewcarcard_edit;

    @BindView(R.id.radiogroupcartype_edit)
    RadioGroup radioGroupCarType_edit;

    @BindView(R.id.radiobuttoncarnomal_edit)
    RadioButton radioButtonCarNomal_edit;

    @BindView(R.id.radiobuttoncarnewenergy_edit)
    RadioButton radioButtonCarNewEnergy_edit;

    //车牌号-手动输入的
    @BindView(R.id.input_view_edit_carinfo)
    InputView mInputViewEditCarInfo;


    //车辆车牌软键盘
    private PopupKeyboard mPopupKeyboard;

    //弹窗的车辆品牌
    private BasePopupView basePopupView_carBrandLargeCategory;
    //选择车系的弹窗
    private BasePopupView basePopupView_carBrandSeriesSmallCategory;
    //一个临时的添加车辆 品牌列表
    private ArrayList<CarBrandLargeCategory> mDataResources_carBrandLarge = new ArrayList<>();
    //一个临时的车系内容
    private ArrayList<CarBrandSeriesLineSmallCategory> mDataResources_carBrandSeriesList = new ArrayList<>();

    //添加 这条档案的id信息；
    private String vehicleId_upLoad = "";
    //这条档案的id;
    private String informationId_upLoad = "";

    //车架号
    private String vin_upLoad = "";
    //车牌号
    private String licenseNumber_upLoad = "";
    // TODO: 2023-08-13 17:30 车辆类型是啥？新车二手车？
    //车辆类型 是新车还是二手车-
    private String vehicleType_upLoad = ArchiveVehicleType.VEHICLETYPE_CAR_NEW.getIndex();
    //车辆品牌
    private String carBranch_upLoad = "";
    //车辆车系
    private String carSeries_upLoad = "";
    //车辆型号
    private String carModel_upLoad = "";
    //车辆发动机号
    private String engineNum_upLoad = "";

    //携带的 从列表过来的这条数据
//    private InformationManageVoExtra extra_InformationManageVo_extra;
    private CarInfoVehicleBean extra_carInfoVehicleBean_extra;

    @OnClick({
            R.id.layoutbuttoncarinfoeditaddsubmit,//保存提交按钮
            R.id.linearlayoutcarbrandnameout_edit,//车辆品牌
            R.id.layoutcarmodelsecondside_edit//车辆车系
    })//
    public void onViewClickInCarEdit(View view) {

        switch (view.getId()) {

            case R.id.layoutbuttoncarinfoeditaddsubmit: {//提交

                KeyboardUtils.hideSoftInput(CarInfoEditActivity.this);

                // TODO: 2023-11-18 17:11 关闭车牌录入键盘
                if (mPopupKeyboard != null && mPopupKeyboard.isShown()) {
                    mPopupKeyboard.dismiss(CarInfoEditActivity.this);
                }

                method_carInfo_upLoad();

                break;
            }

            case R.id.linearlayoutcarbrandnameout_edit: {//品牌

//                if (keyboardUtil.isShow()) {
//                    keyboardUtil.hideKeyboard();
//                }

                //在它之前有没有必选的
                KeyboardUtils.hideSoftInput(mActivityInstance);

                LeadsCarBrandLargeCategorySelectPopu leadsCarBrandLargeCategorySelectPopu = new LeadsCarBrandLargeCategorySelectPopu(CarInfoEditActivity.this,//
                        ExtraValue.MODIFY_ARCHIVE_FILE_ADDSUBMIT_CARBRAND_SELECT,//
                        mDataResources_carBrandLarge);

                leadsCarBrandLargeCategorySelectPopu.setTitleName(getResources().getString(R.string.add_submit_add_model_out));

                if (mDataResources_carBrandLarge != null && !mDataResources_carBrandLarge.isEmpty()) {

                    //直接弹窗：
                    basePopupView_carBrandLargeCategory = new XPopup.Builder(CarInfoEditActivity.this)
                            .hasShadowBg(true)
                            .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                            .isViewMode(true)
                            //.autoDismiss(false)
                            //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                            //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                            //.dismissOnTouchOutside(true)
                            //.notDismissWhenTouchInView()
                            //.moveUpToKeyboard(false)
                            .asCustom(leadsCarBrandLargeCategorySelectPopu)//
                            .show();

                } else {
                    //重新获取一遍接口；

                    gainCarBrandLargeCategory(new GainDataCallBackListener() {
                        @Override
                        public void doSomeThing() {

                            //直接弹窗：
                            basePopupView_carBrandLargeCategory = new XPopup.Builder(CarInfoEditActivity.this)
                                    .hasShadowBg(true)
                                    .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                                    .isViewMode(true)
                                    //.autoDismiss(false)
                                    //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                                    //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                                    //.dismissOnTouchOutside(true)
                                    //.notDismissWhenTouchInView()
                                    //.moveUpToKeyboard(false)
                                    .asCustom(leadsCarBrandLargeCategorySelectPopu)//
                                    .show();

                        }
                    });

                }


                break;
            }

            case R.id.layoutcarmodelsecondside_edit: {//车系

//                if (keyboardUtil.isShow()) {
////                    keyboardUtil.hideKeyboard();
////                }

                KeyboardUtils.hideSoftInput(mActivityInstance);

                //如果车辆品牌是空，那么必须弹窗提示先选择车辆品牌，才能接着获取车辆系的数据;
                if (TextUtils.isEmpty(carBranch_upLoad) || TextUtils.isEmpty(mInputViewEditCarInfo.getNumber().trim())) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.add_submit_add_model_out), true);
                    mAlertView.show();
                    return;
                }

                LeadsCarBrandSeriesLineSmalCategorySelectPopu leadsCarBrandSeriesLineSmalCategorySelectPopu = new LeadsCarBrandSeriesLineSmalCategorySelectPopu(CarInfoEditActivity.this,//
                        ExtraValue.MODIFY_LEAD_ARCHIVE_FILE_ADDSUBMIT_CAR_SERIES_SELECT,//
                        mDataResources_carBrandSeriesList);

                leadsCarBrandSeriesLineSmalCategorySelectPopu.setTitleName(getResources().getString(R.string.car_choose_car_line));

                //必选车辆品牌；
                if (mDataResources_carBrandSeriesList != null && !mDataResources_carBrandSeriesList.isEmpty()) {

                    //直接弹窗：
                    basePopupView_carBrandSeriesSmallCategory = new XPopup.Builder(CarInfoEditActivity.this)
                            .hasShadowBg(true)
                            .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                            .isViewMode(true)
                            //.autoDismiss(false)
                            //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                            //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                            //.dismissOnTouchOutside(true)
                            //.notDismissWhenTouchInView()
                            //.moveUpToKeyboard(false)
                            .asCustom(leadsCarBrandSeriesLineSmalCategorySelectPopu)//
                            .show();

                } else {
                    //重新获取一遍接口；

                    gainCarBrandSeriesLineSmallCategory(carBranch_upLoad, new GainDataCallBackListener() {
                        @Override
                        public void doSomeThing() {

                            //直接弹窗：
                            basePopupView_carBrandSeriesSmallCategory = new XPopup.Builder(CarInfoEditActivity.this)
                                    .hasShadowBg(true)
                                    .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                                    .isViewMode(true)
                                    //.autoDismiss(false)
                                    //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                                    //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                                    //.dismissOnTouchOutside(true)
                                    //.notDismissWhenTouchInView()
                                    //.moveUpToKeyboard(false)
                                    .asCustom(leadsCarBrandSeriesLineSmalCategorySelectPopu)//
                                    .show();

                        }
                    });

                }

                break;
            }
            default:
                break;
        }

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        processExtraData();

        initViews();

        //获取车辆品牌 + 车系的接口，并且车系一定是要先获取的；
        gainDatas();

        //监听品牌
        mCompositeDisposable.add(RxBus.getInstance()//
                .toObserverable(RxBusCarBrand.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarBrand>() {//
                    @Override
                    public void accept(RxBusCarBrand rxBusCarBrand) throws Exception {

                        int actionFlag = rxBusCarBrand.getActionFlag();
                        CarBrandLargeCategory carBrandLargeCategory = rxBusCarBrand.getCarBrandLargeCategory();

                        if (actionFlag == ExtraValue.MODIFY_ARCHIVE_FILE_ADDSUBMIT_CARBRAND_SELECT) {//更改了店铺信息和重新存储id等

                            if (carBrandLargeCategory != null) {

                                carBranch_upLoad = carBrandLargeCategory.getCarBrandId();
//                                LogUtils.d("itchen---mCompositeDisposable---切换车辆品牌-->" + carBrandLargeCategory);

                                if (textviewebrandmodel_edit != null) {
                                    textviewebrandmodel_edit.setText(carBrandLargeCategory.getCarBrandName());
                                }

                                //--------------------------------------------------------------------
                                //车辆品牌一旦切换，车系必须清空重置重新选择
                                carSeries_upLoad = "";
                                if (textviewcarmodelsecond_edit != null) {
                                    textviewcarmodelsecond_edit.setText("");
                                }
                                if (mDataResources_carBrandSeriesList != null && !mDataResources_carBrandSeriesList.isEmpty()) {
                                    mDataResources_carBrandSeriesList.clear();
                                }
                                //--------------------------------------------------------------------

                                //选择完毕品牌立即调用车系
                                gainCarBrandSeriesLineSmallCategory(carBranch_upLoad, null);

                            }

                        }
                    }
                }));

        //监听车系
        mCompositeDisposable.add(RxBus.getInstance()//
                .toObserverable(RxBusCarSeriesLineSmall.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarSeriesLineSmall>() {//
                    @Override
                    public void accept(RxBusCarSeriesLineSmall rxBusCarSeriesLineSmall) throws Exception {

                        int actionFlag = rxBusCarSeriesLineSmall.getActionFlag();
                        CarBrandSeriesLineSmallCategory carBrandSeriesLineSmallCategory = rxBusCarSeriesLineSmall.getCarBrandSeriesLineSmallCategory();

                        if (actionFlag == ExtraValue.MODIFY_LEAD_ARCHIVE_FILE_ADDSUBMIT_CAR_SERIES_SELECT) {//更改了店铺信息和重新存储id等

                            if (carBrandSeriesLineSmallCategory != null) {

                                //车系的id信息；
                                carSeries_upLoad = carBrandSeriesLineSmallCategory.getCarSeriesId();

//                                LogUtils.d("itchen---mCompositeDisposable---切换车辆品牌-车系-->" + carBrandSeriesLineSmallCategory);

                                if (textviewcarmodelsecond_edit != null) {
                                    textviewcarmodelsecond_edit.setText(carBrandSeriesLineSmallCategory.getCarSeriesName());
                                }

                            }
                        }
                    }
                }));

    }

    @Override
    protected int getContentViewId() {
        return R.layout.fileaddmiddle_edit;
    }

    @Override
    protected void onResume() {
        super.onResume();

        // 默认选中第一个车牌号码输入框
//        if (mInputViewEditCarInfo != null) {
//            mInputViewEditCarInfo.performFirstFieldView();
//        }

    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();
    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        toolbarHelper.setTitle(getString(R.string.title_car_content_info));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                KeyboardUtils.hideSoftInput(mActivityInstance);
                methodBack();
            }
        });

        toolbarHelper.setLayoutRight(false, 0, "", null);

//        toolbarHelper.setLayoutRight(true, 3, "保存", new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                KeyboardUtils.hideSoftInput(mActivityInstance);
//                method_carInfo_upLoad();
//            }
//        });

    }

    @Override
    protected void onClickNodata(View v) {

        //这里没有修改的信息

    }

    @Override
    protected void initViews() {

        //直接填充车辆车牌软件盘的绑定
//        if (editviewcarcard_edit != null) {
//            VehicleKeyboardHelper.bind(editviewcarcard_edit);
////            MyVehicleKeyboardHelper myVehicleKeyboardHelper = new MyVehicleKeyboardHelper();
////            MyVehicleKeyboardHelper myVehicleKeyboardHelper = new MyVehicleKeyboardHelper();
//        }

        //车辆品牌
        CommUtils.setText(textviewebrandmodel_edit, extra_carInfoVehicleBean_extra.getCarBranchName());
        //车辆车系
        CommUtils.setText(textviewcarmodelsecond_edit, extra_carInfoVehicleBean_extra.getCarSeriesName());
        //车辆型号
        CommUtils.setText(editviewinputevaluatecarmodel_edit, extra_carInfoVehicleBean_extra.getCarModel());

        //车辆车架号
        CommUtils.setText(editviewcarframe_edit, extra_carInfoVehicleBean_extra.getVin());
        //发动机号
        CommUtils.setText(editviewcarmotor_edit, extra_carInfoVehicleBean_extra.getEngineNum());

        if (radioButtonCarNomal_edit != null) {
            radioButtonCarNomal_edit.setChecked(true);
            radioButtonCarNomal_edit.setTextColor(ColorUtils.getColor(R.color.dark));
        }

        if (radioButtonCarNewEnergy_edit != null) {
            radioButtonCarNewEnergy_edit.setChecked(false);
            radioButtonCarNewEnergy_edit.setTextColor(ColorUtils.getColor(R.color.dark));
        }


        //点击事件内容
        //键盘布局
//        mInputView = (InputView) this.findViewById(R.id.input_view);
        //做键盘绑定
        // 创建弹出键盘
        mPopupKeyboard = new PopupKeyboard(CarInfoEditActivity.this, new MyKeyboardListener() {
            @Override
            public void doSomeThing() {

                //因为车牌不是必填项
                //检验车牌的正确性
                //如果填写了车牌，而恰恰又不是正确的车牌，那么需要校验下：
                method_check_licenseNumber();

            }
        });
        // 弹出键盘内部包含一个KeyboardView，在此绑定输入两者关联。
        mPopupKeyboard.attach(mInputViewEditCarInfo, CarInfoEditActivity.this);
        //设置默认是【河北省】
        mPopupKeyboard.getKeyboardEngine().setLocalProvinceName(getString(R.string.hebei_province));
        //放开第八个？
//        mInputView.set8thVisibility(true);
        // 隐藏确定按钮? 不要隐藏
//        mPopupKeyboard.getKeyboardEngine().setHideOKKey(mHideOKKey);

        //输入变更回调接口
        mPopupKeyboard.getController().addOnInputChangedListener(new OnInputChangedListener() {
            @Override
            public void onChanged(String number, boolean isCompleted) {

                //监听变更为新能源
                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "打印输入的车牌号码-->" + number);
//                mPopupKeyboard.getController().updateNumberLockType(number,true);

                if (isCompleted) {

                    method_check_licenseNumber();

                    mPopupKeyboard.dismiss(CarInfoEditActivity.this);

                } else {
                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "键盘的变动--不是完成状态");
                }


            }

            @Override
            public void onCompleted(String number, boolean isAutoCompleted) {
                mPopupKeyboard.dismiss(CarInfoEditActivity.this);
            }
        });


        //--------------------------------------------------------------------------------------------------------------
        //车辆车牌号--取出填充
        String licenseNumber = extra_carInfoVehicleBean_extra.getLicenseNumber();

        if (!TextUtils.isEmpty(licenseNumber)) {

            if (licenseNumber.length() <= CarLicenseNumberType.LICENSE_NUMBERTYPE_7.getLength()) {

                if (radioButtonCarNomal_edit != null) {
                    radioButtonCarNomal_edit.setChecked(true);
                    radioButtonCarNomal_edit.setTextColor(ColorUtils.getColor(R.color.headmanblue));
                }

                if (radioButtonCarNewEnergy_edit != null) {
                    radioButtonCarNewEnergy_edit.setChecked(false);
                    radioButtonCarNewEnergy_edit.setTextColor(ColorUtils.getColor(R.color.dark));
                }


                //锁定为普通车
                if (mPopupKeyboard != null) {
                    mPopupKeyboard.getController().setSwitchVerify(true).updateNumber(licenseNumber, InputViewSelectKeyboard.KEYBOARD_SHOW_NO.getIndex());
                    //最好关闭软键盘
//                    if (mPopupKeyboard.isShown()){
//                        mPopupKeyboard.dismiss(CarInfoEditActivity.this);
//                    }

                }


            } else if (licenseNumber.length() > CarLicenseNumberType.LICENSE_NUMBERTYPE_7.getLength()) {

                if (radioButtonCarNomal_edit != null) {
                    radioButtonCarNomal_edit.setChecked(false);
                    radioButtonCarNomal_edit.setTextColor(ColorUtils.getColor(R.color.dark));
                }

                if (radioButtonCarNewEnergy_edit != null) {
                    radioButtonCarNewEnergy_edit.setChecked(true);
                    radioButtonCarNewEnergy_edit.setTextColor(ColorUtils.getColor(R.color.headmanblue));
                }

                //锁定为新能源
                if (mPopupKeyboard != null) {
                    //默认是关闭了锁定新能源汽车；
                    mPopupKeyboard.getController().setSwitchVerify(true).updateNumberLockType(licenseNumber, true, InputViewSelectKeyboard.KEYBOARD_SHOW_NO.getIndex());
                    //最好关闭软键盘
//                    if (mPopupKeyboard.isShown()){
//                        mPopupKeyboard.dismiss(CarInfoEditActivity.this);
//                    }
                }

            }

        }

        //--------------------------------------------------------------------------------------------------------------

        if (radioGroupCarType_edit != null) {

            radioGroupCarType_edit.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {

                    if (checkedId == R.id.radiobuttoncarnomal_edit) {

                        //选中了普通车牌，那么不用锁定是新能源.
                        try {

                            radioButtonCarNomal_edit.setChecked(true);
                            radioButtonCarNomal_edit.setTextColor(ColorUtils.getColor(R.color.headmanblue));

                            radioButtonCarNewEnergy_edit.setChecked(false);
                            radioButtonCarNewEnergy_edit.setTextColor(ColorUtils.getColor(R.color.dark));

                            //如果用户都填写了车牌号，刚好是8位，那么删除掉最后一位
                            int length = mInputViewEditCarInfo.getNumber().length();

                            if (length > CarLicenseNumberType.LICENSE_NUMBERTYPE_7.getLength()) {


                                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "是新能源-需要删除掉最后一个");

                                //删除掉最后一个
                                mInputViewEditCarInfo.removeLastCharOfNumber();

                            }

                            //do
                            if (mPopupKeyboard.getController() != null) {

                                //重新更新下数字
                                mPopupKeyboard.getController().updateNumber(mInputViewEditCarInfo.getNumber(), InputViewSelectKeyboard.KEYBOARD_SHOW_YES.getIndex());
                                //重新更新下校验规则
                                mPopupKeyboard.getController()
                                        .setDebugEnabled(true)
                                        .setSwitchVerify(true)
                                        .updateNumberLockType(mInputViewEditCarInfo.getNumber(), false, InputViewSelectKeyboard.KEYBOARD_SHOW_YES.getIndex());

                            }

                        } catch (Exception e) {
                            //catch
                            e.printStackTrace();
                        }


                    } else if (checkedId == R.id.radiobuttoncarnewenergy_edit) {

                        //选中的是新能源的按钮

                        try {

                            radioButtonCarNomal_edit.setChecked(false);
                            radioButtonCarNomal_edit.setTextColor(ColorUtils.getColor(R.color.dark));

                            radioButtonCarNewEnergy_edit.setChecked(true);
                            radioButtonCarNewEnergy_edit.setTextColor(ColorUtils.getColor(R.color.headmanblue));

                            //do
                            //锁定是新能源
                            if (mPopupKeyboard.getController() != null) {

                                mPopupKeyboard.getController()//
                                        .setDebugEnabled(true)//
                                        .setSwitchVerify(true)
                                        .updateNumberLockType(mInputViewEditCarInfo.getNumber(), true, InputViewSelectKeyboard.KEYBOARD_SHOW_YES.getIndex());//

                            }

                        } catch (Exception e) {
                            //catch
                            e.printStackTrace();
                        }

                    }

                }
            });
        }


//        CommUtils.setText(editviewcarcard_edit, extra_carInfoVehicleBean_extra.getLicenseNumber());

        //对输入车牌的监听
        //告诉系统不要弹出来软键盘
//        editviewcarcard_edit.setShowSoftInputOnFocus(false);

        //输入监听
//        editviewcarcard_edit.addTextChangedListener(new TextWatcher() {
//
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//                //暂时不处理
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//
//                String text = s.toString();
//
//                //checkViewState(text);
//
//                if (s.length() == 8) {
//
//                    //layoutPlateNumber.setBackgroundResource(R.drawable.btn_round_blue);
//                    imgIcon.setVisibility(View.VISIBLE);
//
//                } else {
//
//                    //layoutPlateNumber.setBackgroundResource(R.drawable.btn_round_green);
//                    imgIcon.setVisibility(View.GONE);
//
//                }
//
//                // TODO: 2023-09-01 11:18 车牌的监听暂时不处理， 将来再处理；
////                if (text.contains("港") || text.contains("澳") || text.contains("学")) {
////
////                    editViewInputCarNumber.setFilters(new InputFilter[]{new InputFilter.LengthFilter(7)});
////
////                } else {
////
////                    editViewInputCarNumber.setFilters(new InputFilter[]{new InputFilter.LengthFilter(8)});
////
////                }
//
//            }
//
//            @Override
//            public void afterTextChanged(Editable s) {
//
//                //暂时不填充
//                //如果是一个正确车牌，那么，就校验这个车牌是否在黑名单内
//
//            }
//        });


        //监听输入过程之中 车牌号是否正确
        //------------------------------------------------------------------------------------------
        //输入完毕校验车牌的正确性，如果是这个正确的输入完毕就校验一次【车牌是否是在黑名单】
//        mCompositeDisposable.add(RxTextView.afterTextChangeEvents(editviewcarcard_edit)
//                .debounce(ConstantApi.TIME_DELAY500, TimeUnit.MILLISECONDS)
//                .skip(ConstantApi.SKIP_CAR_NUMBER)//过滤掉前4个都行 【京Q58A77】
//                .observeOn(AndroidSchedulers.mainThread())//
//                .subscribeOn(AndroidSchedulers.mainThread())//
//                .subscribe(new Consumer<TextViewAfterTextChangeEvent>() {
//                    @Override
//                    public void accept(TextViewAfterTextChangeEvent textViewAfterTextChangeEvent) throws Throwable {
//
//                        try {
//
//                            //do
//                            if (textViewAfterTextChangeEvent != null) {
//
//                                String editResult = textViewAfterTextChangeEvent.getView().getText().toString();
//
//                                //LogUtils.d(ConstantApi.LOGCAT_NOMAL + "输入完毕的数据是-->" + editResult);
//
//                                //如果小区id不是空，并且车牌也不是空；  && !TextUtils.isEmpty(upload_CommunityId)
//                                if (!TextUtils.isEmpty(editResult)) {
//
//                                    //校验【不是空】说明输入的是正确的车牌，那么校验【该完整车牌是否在黑名单之中】
//                                    //校验如果是空，说明输入的是错误的车牌
//                                    if (VehiclePlateNoUtil.getVehiclePlateNo(editviewcarcard_edit.getText().toString().trim()) == null) {
//
////                                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "手机校验是正确的车牌");
//
//                                        String result = getString(R.string.please_input_carnumersure);
//                                        PopTip.show(result).iconWarning();
//
////                                        if (!TextUtils.isEmpty(upload_CommunityId)) {//调用接口 校验是不是【在该小区的黑名单列表内】
////                                            method_checkVisitorCarIsSure_afterTextChange();
////                                        } else {
//////                                            LogUtils.d(ConstantApi.LOGCAT_NOMAL + "校验发现小区没有选择，提示选择小区，然后再次校验-");
////                                        }
//                                    }
//                                }
//                            }
//
//                        } catch (Exception e) {
//                            //catch
//                            if (e != null) {
//                                //上传操作日志
////                                new ApiRequestSubListener<>() {
////                                }.addLogInApiRequestListener(mActivityInstance,//
////                                        ConstantApi.REQUEST_METHOD_POST,//
////                                        "只是校验车牌出错",//
////                                        null,//
////                                        "校验车牌的正确性出错" + e.getMessage().toString());
////                                e.printStackTrace();
//                            }
//                        }
//                    }
//                }));

    }

    //校验车牌的通用方法
    private void method_check_licenseNumber() {
        //检验车牌的正确定
        licenseNumber_upLoad = mInputViewEditCarInfo.getNumber().trim();

        if (!TextUtils.isEmpty(licenseNumber_upLoad)) {
            //验证车牌的正确性
            if (VehiclePlateNoUtil.getVehiclePlateNo(licenseNumber_upLoad) == null) {
                CommUtils.checkDialog(mAlertView);
                mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.please_input_carnumersure), true);
                mAlertView.show();
                return;
            }

        } else {
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "输入的车牌号是空值");
        }
    }

    @Override
    protected void gainDatas() {

        if (NetworkUtils.isConnected()) {

            //获取 车辆品牌列表
            gainCarBrandLargeCategory(null);

            //车系是必须先调用，因为 携带过来有品牌id,可能仅仅是修改车系
            gainCarBrandSeriesLineSmallCategory(carBranch_upLoad, null);

            //获取合同类型
//            gainContractType(null);

        }


    }

    //获取车辆车系；
    private void gainCarBrandSeriesLineSmallCategory(String _carBrandId, GainDataCallBackListener _gainDataCallBackListener) {

        //
        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.carBrandId, _carBrandId);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETCARSERIESLIST);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getCarSeriesList_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getCarSeriesList(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(CarInfoEditActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<CarBrandSeriesLineSmallCategory>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {

                        //清空
                        CarBrandSeriesLineDaoManager.getInstance().deleteAllCarSeries();

                        //如果监听器不是空就创建进度圈圈
                        if (_gainDataCallBackListener != null) {
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                        }

                    }
                }).subscribe(new Consumer<ArrayList<CarBrandSeriesLineSmallCategory>>() {
                    @Override
                    public void accept(ArrayList<CarBrandSeriesLineSmallCategory> carBrandSeriesLineSmallCategories) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);

                        if (mDataResources_carBrandSeriesList != null && !mDataResources_carBrandSeriesList.isEmpty()) {
                            mDataResources_carBrandSeriesList.clear();
                        }

                        if (carBrandSeriesLineSmallCategories != null && !carBrandSeriesLineSmallCategories.isEmpty()) {

                            if (mDataResources_carBrandSeriesList != null) {

                                mDataResources_carBrandSeriesList.addAll(carBrandSeriesLineSmallCategories);
                                //先排序
//                                CommUtils.CollectionsSort_CarBrandSeriesLineSmallCategory_UK(mDataResources_carBrandSeriesList);
                                CommUtils.CollectionsSort_CarBrandSeriesLineSmallCategory_CHINA(mDataResources_carBrandSeriesList);
                                //filldatas
                                CarBrandSeriesLineDaoManager.getInstance().insertMultCarSeries(mDataResources_carBrandSeriesList);
                            }

                        }

                        if (_gainDataCallBackListener != null) {
                            _gainDataCallBackListener.doSomeThing();
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        //
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                });

    }

    //获取车辆品牌；
    private void gainCarBrandLargeCategory(GainDataCallBackListener _gainDataCallBackListener) {

        HashMap<String, Object> map = new HashMap<>();
        //map.put(Parameterkey., yourName);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETCARBRANDFORVEHICLEPAGE);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getCarBrandForVehiclePage_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getCarBrandForVehiclePage(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(CarInfoEditActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<CarBrandLargeCategory>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                        //关闭弹窗
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {

                        //清理车辆品牌数据库内容
                        CarBrandLargeCategoryDaoManager.getInstance().deleteAllCarBrand();
                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                    }
                }).subscribe(new Consumer<ArrayList<CarBrandLargeCategory>>() {
                    @Override
                    public void accept(ArrayList<CarBrandLargeCategory> carBrandLargeCategories) throws Throwable {

                        if (mDataResources_carBrandLarge != null && !mDataResources_carBrandLarge.isEmpty()) {
                            mDataResources_carBrandLarge.clear();
                        }

                        if (carBrandLargeCategories != null && !carBrandLargeCategories.isEmpty()) {

                            if (mDataResources_carBrandLarge != null) {

                                mDataResources_carBrandLarge.addAll(carBrandLargeCategories);
                                //先排序
//                                CommUtils.CollectionsSort_CarBrandLargeCategory_UK(mDataResources_carBrandLarge);
                                CommUtils.CollectionsSort_CarBrandLargeCategory_CHINA(mDataResources_carBrandLarge);

                                //填充车辆品牌的数据
                                CarBrandLargeCategoryDaoManager.getInstance().insertMultCarBrand(mDataResources_carBrandLarge);

                            }

                        }

                        CommUtils.checkMaterialDialog(materialDialog);

                        //立即获取车系？没有必要
                        if (_gainDataCallBackListener != null) {
                            _gainDataCallBackListener.doSomeThing();
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                });
    }

    //这里仅仅是修改客户信息
    private void method_remedialItems_addSubmit_upLoad(ArrayList<FileCarInfoAddSubmitUpLoadSingle> _fileCarInfoAddSubmit_upLoadList) {

//                ArchiveUpdateType
//                UPDATETYPE_1("1","整体修改"),
//                UPDATETYPE_2("2","只修改客户信息"),
//                UPDATETYPE_3("3","只修改附件"),
//                UPDATETYPE_4("4","只修改合同"),
//                UPDATETYPE_5("5","只修改车辆信息");

        HashMap<String, Object> map = new HashMap<>();

        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
        map.put(Parameterkey.informationId, informationId_upLoad);//2023-11-10 09:42:06 发现接口需要携带 informationId
        map.put(Parameterkey.vehicleId, vehicleId_upLoad);//携带过来有数据  2023-11-10 09:41:58
        map.put(Parameterkey.updateType, ArchiveUpdateType.UPDATETYPE_5.getIndex());

//        map.put(Parameterkey.vehicleType, vehicleType_upLoad);//车辆类型--是新车还是二手车
        map.put(Parameterkey.vehicleType, ArchiveVehicleType.VEHICLETYPE_CAR_NEW.getIndex());//车辆类型--是新车还是二手车


//        map.put(Parameterkey.licenseNumber, licenseNumber_upLoad);//车牌号
//        map.put(Parameterkey.vin, vin_upLoad);//车架号
//        map.put(Parameterkey.carBranch, carBranch_upLoad);//品牌
//        map.put(Parameterkey.carSeries, carSeries_upLoad);//车系
//        map.put(Parameterkey.carModel, carModel_upLoad);//车型
//        map.put(Parameterkey.engineNum, engineNum_upLoad);//发动机号

        map.put(Parameterkey.vehicleList, _fileCarInfoAddSubmit_upLoadList);//发动机号

//        map.put(Parameterkey.clientManage, clientManage_upLoad);

//        updateType
//        1: 整体修改 或者传递空值null
//        2: 只修改客户信息
//        3: 只修改附件
//        4: 只修改合同
//        5: 只修改车辆信息

//        {
//            "clientManage":{
//            "clientName":"张三",
//                    "idCard":"13010818890212122435",
//                    "gender":1,
//                    "age":23,
//                    "phone":"151626332333",
//                    "wechatNumber":"Z_s1234",
//                    "email":"Z_s1234@qq.com",
//                    "address":"河北省石家庄裕华区盛邦花园1区",
//                    "companyDetail":"",
//                    "position":"运维",
//        },
//                "vehicleId":6,
//                "vin":"车架号",
//                "licenseNumber":"冀A88888",
//                "vehicleType":"1",
//                "carBranch":"大众",
//                "carModel":"朗逸运动款",
//                "carSeries":"朗逸",
//                "engineNum":"发动机号",
//                "archivesManageList":[],
//            "informationAccessoryList":[
//            {
//                "filePath":"http://地址",
//                    "fileName":"文件名称",
//                    "fileSize":1023
//            }
//    ]
//        }


//
//        map.put(Parameterkey.archivesManageList, _archivesManageList);
//        map.put(Parameterkey.informationAccessoryList, _informationAccessoryList);//是否产生费用

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_ADDINFORMATIONMANAGE_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.addInformationManage_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        //上传的json内容是
        String jsonObject_UpLoad = JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue);
//        LogUtils.d(ConstantSign.LOGCAT_NOMAL, jsonObject_UpLoad);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .updateInformationManage(RequestBody.create(jsonObject_UpLoad, MediaType.parse(ApiService.HEADER_JSON)))
                .compose(CarInfoEditActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<String>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        if (!TextUtils.isEmpty(serverMessage)) {
                            ToastUtils.showShort(serverMessage);
                        }

                    }
                })).subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String stringValue) throws Throwable {

                        //TipDialog.show(StringUtils.getString(R.string.add_submit_success), WaitDialog.TYPE.SUCCESS);

                        //直接刷新档案详情
                        EventArchiveDetail eventArchiveDetail = new EventArchiveDetail();
                        eventArchiveDetail.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_ARCHIVEFILE_DETAIL);
                        EventBus.getDefault().post(eventArchiveDetail);

                        methodSubmitSuccess(CarInfoEditActivity.this, new DoSomeThingListener() {
                            @Override
                            public void doSomeThing() {
                                //页面关闭直接回到档案管理主页列表页面
                                methodBack();
                            }
                        });

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                    }
                });

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

            if (mPopupKeyboard.isShown()) {
                mPopupKeyboard.dismiss(CarInfoEditActivity.this);
                return false;
            }

//            else {
//                mPopupKeyboard.show(SmartGoOutActivity.this);
//            }

//            if (keyboardUtil.isShow()) {
//                keyboardUtil.hideKeyboard();
//                return false;
//            }

        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        //做一些内存释放的信息；
        if (basePopupView_carBrandLargeCategory != null) {
            basePopupView_carBrandLargeCategory.onDestroy();
            basePopupView_carBrandLargeCategory = null;
        }

        if (basePopupView_carBrandSeriesSmallCategory != null) {
            basePopupView_carBrandSeriesSmallCategory.onDestroy();
            basePopupView_carBrandSeriesSmallCategory = null;
        }

        if (extra_carInfoVehicleBean_extra != null) {
            extra_carInfoVehicleBean_extra = null;
        }

    }

    @Override
    protected void methodBack() {

        methodBackFinish();

    }

    //添加 提交的车辆信息
    private void method_carInfo_upLoad() {

        //验证
        //-----------------------------------------------------------------------------------

        //中间的车辆上传条目的信息
        //车辆类型,默认传递1，是新车类型
        vehicleType_upLoad = ArchiveVehicleType.VEHICLETYPE_CAR_NEW.getIndex();
        //车辆的品牌--仅仅上传品牌的id即可
        //carBranch_upLoad = ;
        //车辆的车系--仅仅上传车辆车系id
        //carSeries_upLoad  = ""
        //车型
        carModel_upLoad = editviewinputevaluatecarmodel_edit.getText().toString().trim();
        //车牌号
//        licenseNumber_upLoad = editviewcarcard_edit.getText().toString().trim();
        licenseNumber_upLoad = mInputViewEditCarInfo.getNumber().trim();
        //车架号
        vin_upLoad = editviewcarframe_edit.getText().toString().trim();
        //发动机号
        engineNum_upLoad = editviewcarmotor_edit.getText().toString().trim();

        //-----------------------------------------------------------------------------------

        //验证车辆的品牌
        if (TextUtils.isEmpty(carBranch_upLoad)) {
            CommUtils.checkDialog(mAlertView);
            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.select_lead_carbrand_toast), true);
            mAlertView.show();
            return;
        }

        //验证车辆的品牌
        if (TextUtils.isEmpty(carSeries_upLoad)) {
            CommUtils.checkDialog(mAlertView);
            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.select_lead_carbrandseries_toast), true);
            mAlertView.show();
            return;
        }

        //验证车辆车型
        if (TextUtils.isEmpty(carModel_upLoad)) {
            CommUtils.checkDialog(mAlertView);
            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.carname_upload), true);
            mAlertView.show();
            return;
        }

        //验证车架号
        if (TextUtils.isEmpty(vin_upLoad)) {
            CommUtils.checkDialog(mAlertView);
            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.car_number_car_frame), true);
            mAlertView.show();
            return;
        }

        //车牌号不是必填项了，但是如果输入了车牌，那么就要校验车牌的正确性
        //验证车辆--车牌号
//        if (TextUtils.isEmpty(licenseNumber_upLoad)) {
//            CommUtils.checkDialog(mAlertView);
//            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.car_number_hint), true);
//            mAlertView.show();
//            return;
//        }

        if (!TextUtils.isEmpty(licenseNumber_upLoad)) {

            //输入完毕车牌号 立即校验输入车牌的正确性
            if (VehiclePlateNoUtil.getVehiclePlateNo(licenseNumber_upLoad) == null) {
                CommUtils.checkDialog(mAlertView);
                mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.please_input_carnumersure), true);
                mAlertView.show();
                return;
            }

        }


        //---------------------------------------------------------------------
        //如果都校验通过，那么改为集合提交
        ArrayList<FileCarInfoAddSubmitUpLoadSingle> fileCarInfoAddSubmit_upLoadList = new ArrayList<>();

        FileCarInfoAddSubmitUpLoadSingle fileCarInfoAddSubmitUpLoad = new FileCarInfoAddSubmitUpLoadSingle();
        //车辆的单条id
        fileCarInfoAddSubmitUpLoad.setVehicleId(vehicleId_upLoad);
        //车辆品牌
        fileCarInfoAddSubmitUpLoad.setCarBranch(carBranch_upLoad);
        //车辆车系
        fileCarInfoAddSubmitUpLoad.setCarSeries(carSeries_upLoad);
        //车型
        fileCarInfoAddSubmitUpLoad.setCarModel(carModel_upLoad);
        //车架号
        fileCarInfoAddSubmitUpLoad.setVin(vin_upLoad);
        //发动机号
        fileCarInfoAddSubmitUpLoad.setEngineNum(engineNum_upLoad);
        //车牌号
        fileCarInfoAddSubmitUpLoad.setLicenseNumber(licenseNumber_upLoad);

        //提交的内容列表；
        fileCarInfoAddSubmit_upLoadList.add(fileCarInfoAddSubmitUpLoad);

        //---------------------------------------------------------------------

        //直接提交
        CommUtils.checkDialog(mAlertView);
        mAlertView = new AlertView(StringUtils.getString(R.string.clearaddorsubmitsuretitletips), //提示
                StringUtils.getString(R.string.middlelowmodifychange),//提示内容：确定修改吗
                StringUtils.getString(R.string.clearcachecancel), //取消
                new String[]{StringUtils.getString(R.string.clearaddorsubmitsure)},//确定
                null, mActivityInstance, AlertView.Style.Alert, new OnItemClickListener() {//
            @Override
            public void onItemClick(Object o, int position) {

                if (position != AlertView.CANCELPOSITION) {

                    method_remedialItems_addSubmit_upLoad(fileCarInfoAddSubmit_upLoadList);

                }
            }
        });

        mAlertView.setCancelable(true);
        mAlertView.show();

    }

    @Override
    public void processExtraData() {

        Bundle extras_bundle = this.getIntent().getExtras();

        if (extras_bundle != null) {

            //flag_jumpfrom_where_type = extras_bundle.getString(ExtraKey.EXTRA_JUMPFROM_WHERE_TYPE);

            extra_carInfoVehicleBean_extra = extras_bundle.getParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA);
            LogUtils.json(ConstantSign.LOGCAT_NOMAL + "携带的车辆信息-->", extra_carInfoVehicleBean_extra);

            if (extra_carInfoVehicleBean_extra != null) {

                //车辆单条信息的id
                vehicleId_upLoad = extra_carInfoVehicleBean_extra.getVehicleId();
                //档案的id
                informationId_upLoad = extra_carInfoVehicleBean_extra.getInformationId();
                //车辆品牌id
                carBranch_upLoad = extra_carInfoVehicleBean_extra.getCarBranch();
                //车辆车系id
                carSeries_upLoad = extra_carInfoVehicleBean_extra.getCarSeries();

            }

        }

    }
}